home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / Ang261Lib.lha / src / staffs.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  6KB  |  263 lines

  1. /*
  2.  * staffs.c: staff code 
  3.  *
  4.  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke 
  5.  *
  6.  * This software may be copied and distributed for educational, research, and
  7.  * not for profit purposes provided that this copyright and statement are
  8.  * included in all such copies. 
  9.  */
  10.  
  11. #include "constant.h"
  12. #include "monster.h"
  13. #include "config.h"
  14. #include "types.h"
  15. #include "externs.h"
  16.  
  17. #ifdef USG
  18. #include <string.h>
  19. #else
  20. #include <strings.h>
  21. #endif
  22.  
  23.  
  24. /* Use a staff.                    -RAK-     */
  25. void 
  26. use()
  27. {
  28.     int32u                i;
  29.     int                   j, k, item_val, chance, y, x;
  30.     register int          ident;
  31.     register struct misc *m_ptr;
  32.     register inven_type  *i_ptr;
  33.  
  34.     free_turn_flag = TRUE;
  35.     if (inven_ctr == 0)
  36.     msg_print("But you are not carrying anything.");
  37.     else if (!find_range(TV_STAFF, TV_NEVER, &j, &k))
  38.     msg_print("You are not carrying any staffs.");
  39.     else if (get_item(&item_val, "Use which staff?", j, k, 0)) {
  40.     i_ptr = &inventory[item_val];
  41.     free_turn_flag = FALSE;
  42.     m_ptr = &py.misc;
  43.     chance = m_ptr->save + stat_adj(A_INT)
  44.         - (int)(i_ptr->level>50?50:i_ptr->level)
  45.         + (class_level_adj[m_ptr->pclass][CLA_DEVICE] * m_ptr->lev / 3);
  46.     if (py.flags.confused > 0)
  47.         chance = chance / 2;
  48.     if ((chance < USE_DEVICE) && (randint(USE_DEVICE - chance + 1) == 1))
  49.         chance = USE_DEVICE;   /* Give everyone a slight chance */
  50.     if (chance <= 0)
  51.         chance = 1;
  52.     if (randint(chance) < USE_DEVICE)
  53.         msg_print("You failed to use the staff properly.");
  54.     else if (i_ptr->p1 > 0) {
  55.         i = i_ptr->flags;
  56.         ident = FALSE;
  57.         (i_ptr->p1)--;
  58.         switch (i) {
  59.           case ST_HEALING:
  60.         ident = hp_player(300);
  61.         if (py.flags.stun > 0) {
  62.             if (py.flags.stun > 50) {
  63.             py.misc.ptohit += 20;
  64.             py.misc.ptodam += 20;
  65.             } else {
  66.             py.misc.ptohit += 5;
  67.             py.misc.ptodam += 5;
  68.             }
  69.             py.flags.stun = 0;
  70.             ident = TRUE;
  71.             msg_print("Your head stops stinging.");
  72.         }
  73.         if (py.flags.cut > 0) {
  74.             py.flags.cut = 0;
  75.             ident = TRUE;
  76.             msg_print("You feel better.");
  77.         }
  78.         break;
  79.           case ST_GENOCIDE:
  80.         genocide(FALSE);
  81.         ident = TRUE;
  82.         break;
  83.           case ST_PROBE:
  84.         probing();
  85.         ident = TRUE;
  86.         break;
  87.           case ST_IDENTIFY:
  88.         ident_spell();
  89.         ident = TRUE;
  90.         break;
  91.           case ST_HOLYNESS:
  92.         dispel_creature(EVIL, 120);
  93.         protect_evil();
  94.         cure_poison();
  95.         remove_fear();
  96.         hp_player(50);
  97.         if (py.flags.stun > 0) {
  98.             if (py.flags.stun > 50) {
  99.             py.misc.ptohit += 20;
  100.             py.misc.ptodam += 20;
  101.             } else {
  102.             py.misc.ptohit += 5;
  103.             py.misc.ptodam += 5;
  104.             }
  105.             py.flags.stun = 0;
  106.             ident = TRUE;
  107.             msg_print("Your head stops stinging.");
  108.         }
  109.         if (py.flags.cut > 0) {
  110.             py.flags.cut = 0;
  111.             ident = TRUE;
  112.             msg_print("You feel better.");
  113.         }
  114.         ident = TRUE;
  115.         break;
  116.           case ST_MAGI:
  117.         if (res_stat(A_INT)) {
  118.             msg_print("You have a warm feeling.");
  119.             ident = TRUE;
  120.         }
  121.         m_ptr = &py.misc;
  122.         if (m_ptr->cmana < m_ptr->mana) {
  123.             m_ptr->cmana = m_ptr->mana;
  124.             ident = TRUE;
  125.             msg_print("Your feel your head clear.");
  126.             prt_cmana();
  127.         }
  128.         break;
  129.           case ST_POWER:
  130.         dispel_creature(0xFFFFFFFFL, 120);
  131.         break;
  132.           case ST_SURROUND:
  133.         map_area();
  134.         ident = TRUE;
  135.         break;
  136.           case ST_LIGHT:
  137.         ident = light_area(char_row, char_col, damroll(2, 10), 2);
  138.         break;
  139.           case ST_DR_LC:
  140.         ident = detect_sdoor();
  141.         break;
  142.           case ST_TRP_LC:
  143.         ident = detect_trap();
  144.         break;
  145.           case ST_TRE_LC:
  146.         ident = detect_treasure();
  147.         break;
  148.           case ST_OBJ_LC:
  149.         ident = detect_object();
  150.         break;
  151.           case ST_TELE:
  152.         teleport(100);
  153.         ident = TRUE;
  154.         break;
  155.           case ST_EARTH:
  156.         ident = TRUE;
  157.         earthquake();
  158.         break;
  159.           case ST_SUMMON:
  160.         ident = FALSE;
  161.         for (k = 0; k < randint(4); k++) {
  162.             y = char_row;
  163.             x = char_col;
  164.             ident |= summon_monster(&y, &x, FALSE);
  165.         }
  166.         break;
  167.           case ST_DEST:
  168.         ident = TRUE;
  169.         destroy_area(char_row, char_col);
  170.         break;
  171.           case ST_STAR:
  172.         ident = TRUE;
  173.         starlite(char_row, char_col);
  174.         break;
  175.           case ST_HAST_MN:
  176.         ident = speed_monsters(1);
  177.         break;
  178.           case ST_SLOW_MN:
  179.         ident = speed_monsters(-1);
  180.         break;
  181.           case ST_SLEE_MN:
  182.         ident = sleep_monsters2();
  183.         break;
  184.           case ST_CURE_LT:
  185.         ident = hp_player(randint(8));
  186.         break;
  187.           case ST_DET_INV:
  188.         ident = detect_invisible();
  189.         break;
  190.           case ST_SPEED:
  191.         if (py.flags.fast == 0)
  192.             ident = TRUE;
  193.         if (py.flags.fast <= 0)
  194.             py.flags.fast += randint(30) + 15;
  195.         else
  196.             py.flags.fast += randint(5);
  197.         break;
  198.           case ST_SLOW:
  199.         if (py.flags.slow == 0)
  200.             ident = TRUE;
  201.         py.flags.slow += randint(30) + 15;
  202.         break;
  203.           case ST_REMOVE:
  204.         if (remove_curse()) {
  205.             if (py.flags.blind < 1)
  206.             msg_print("The staff glows blue for a moment..");
  207.             ident = TRUE;
  208.         }
  209.         break;
  210.           case ST_DET_EVI:
  211.         ident = detect_evil();
  212.         break;
  213.           case ST_CURING:
  214.         if ((cure_blindness()) || (cure_poison()) ||
  215.             (cure_confusion()) || (py.flags.stun > 0) || (py.flags.cut > 0))
  216.             ident = TRUE;
  217.         if (py.flags.stun > 0) {
  218.             if (py.flags.stun > 50) {
  219.             py.misc.ptohit += 20;
  220.             py.misc.ptodam += 20;
  221.             } else {
  222.             py.misc.ptohit += 5;
  223.             py.misc.ptodam += 5;
  224.             }
  225.             py.flags.stun = 0;
  226.             msg_print("Your head stops stinging.");
  227.         } else if (py.flags.cut > 0) {
  228.             py.flags.cut = 0;
  229.             msg_print("You feel better.");
  230.         }
  231.         break;
  232.           case ST_DSP_EVI:
  233.         ident = dispel_creature(EVIL, 60);
  234.         break;
  235.           case ST_DARK:
  236.         ident = unlight_area(char_row, char_col);
  237.         break;
  238.           default:
  239.         msg_print("Internal error in staffs()");
  240.         break;
  241.         }
  242.         if (ident) {
  243.         if (!known1_p(i_ptr)) {
  244.             m_ptr = &py.misc;
  245.         /* round half-way case up */
  246.             m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) /
  247.             m_ptr->lev;
  248.             prt_experience();
  249.  
  250.             identify(&item_val);
  251.             i_ptr = &inventory[item_val];
  252.         }
  253.         } else if (!known1_p(i_ptr))
  254.         sample(i_ptr);
  255.         desc_charges(item_val);
  256.     } else {
  257.         msg_print("The staff has no charges left.");
  258.         if (!known2_p(i_ptr))
  259.         add_inscribe(i_ptr, ID_EMPTY);
  260.     }
  261.     }
  262. }
  263.